package com.chaopei.day02;

/**
 * @Author Corday 天涯
 * @Date 2022/3/4 9:15
 */
public class MyMethod {
    public static void main(String[] args) {
        //myMethod1();
//        myMethod2(10.5);
        System.out.println(myMethod3());
    }
// 声明与定义方法有种方式
//    1.无返回值，无参数
    public  static void myMethod1(){
        //数值计算求和
        for(int i=0,j=6;i<6||j>1;i++,j--){
            System.out.println(i+"+"+j+"="+(i+j));
        }
    }
//   2.无返回值，有参数
    public  static void myMethod2(double r){
        double PI = Math.PI;
        double area=0;
        area = r*r*PI;
        //请将结果精确到小数位后三位，要四舍五入
        String result = String.format("%.3f",area);
        //System.out.println("半径为"+r+"圆的面积为："+area);
        System.out.println("半径为"+r+"圆的面积为："+result);
    }
//  3.有返回值，无参数
    public static  String myMethod3(){
        String json1 ="{'name':'tom','gender':'男','face':99}";
        String json2 ="{'info':{'name':'bean','gender':'男'}}";
        String arr="[{'name':'mary','gender':'女'},{'name':'nick','gender':'男'}]";
        String json="{'add':'郑州市纽约大街','arr':[{'name':'小美','gender':'女'}," +
                "{'name':'小帅','gender':'男'}],'info':{'salary':9999.8,'face':98}}";
        return json;
    }
//    4.有返回值，有参数,以下为方法的重载
    public static  Double calcArea(double r){
        return Math.PI*r*r;//自动装箱
    }
    public static  Double calcArea(double w,double h){
        return w*h;
    }
    public static  Double calcArea(int bottom,int heigh){
        return (double)(bottom*heigh);
    }
}
